﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SetMaterialControl.ascx.cs" Inherits="ZLCMS.Web.SystemManage.weixin.Material.SetMaterialControl" %>
<input id="matfield" name="mat.id" value="<%=Material.Id %>" type="hidden" />
<input id="matfield_ttl" name="mat.orgName" class="readonly required" type="text" style="margin-top:2px" value="<%=Material.Title %>"  onblur="loadMaterialList($(this))"/>
<a class="button select_material" href="/SystemManage/Weixin/Material/SelectMaterialList.aspx" lookupGroup="mat"><span>选择</span></a>
<a class="button" onclick="openTextMaterialDialog()" title="文本素材"><span>文本素材</span></a>
               
<script type="text/javascript">

    function openTextMaterialDialog() {
        $.pdialog.open('/SystemManage/Weixin/Material/EditTextMaterialDialog.aspx?uid=' + $('#matfield', navTab.getCurrentPanel()).val(),
            'EditTextMaterialDialog', '文本素材', { width: 800, height: 600, mask: true });
    }
    function loadMaterialList(ui) {
        ui.ExecuteCommand({
            successCallBack: function (result, totalCount) {
                $('#matfield_ttl', navTab.getCurrentPanel()).val(result.Title);
                $('#matfield', navTab.getCurrentPanel()).val(result.Id);
            }, errorCallback: function (errorCode, msg) {
                alertMsg.error("找不到相应的素材", { okCall: function () {
                    $('.select_material', navTab.getCurrentPanel()).attr('href', '/SystemManage/Weixin/Material/SelectMaterialList.aspx?title=' + ui.val()).click();
                }
                });
            }
        }, "LoadMatrialByTitle", {
            Title: ui.val()
        });
    }

    $.pdialog.closeDialogCallback = function (param) {
        $('#matfield_ttl', navTab.getCurrentPanel()).val(param.Title);
        $('#matfield', navTab.getCurrentPanel()).val(param.Id);
    }
</script>